package com.tensai.study.java.newconcept.typereactiveprogram.reactor.flux;

import com.tensai.utils.BasicUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Test;
import reactor.core.publisher.Flux;

import java.util.Arrays;

/**
 * @author Tensai
 */
public class CombineLatestTest {

	@Test
	public void test() {
		Flux c = Flux.range(2, 6).map(i -> new DataVo(i, "A"));
		Flux d = Flux.range(5, 6).map(i -> new DataVo(i, "B"));
		Flux f = Flux.range(4, 6).map(i -> new DataVo(i, "C"));

		Flux.combineLatest(Arrays::toString, c, d, f)
				.subscribe(i -> System.out.println("  ->" + i));

		BasicUtil.sleep(10);

	}

	@Data
	@AllArgsConstructor
	static class DataVo {

		private int a;

		private String b;

		@Override
		public String toString() {
			return "[" + a +", " + b + "]";
		}
	}
}
